home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / t410x.trm < prev    next >
Text File  |  1993-09-15  |  5KB  |  243 lines

  1. /*
  2.  * $Id: t410x.trm%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - t410x.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports: Tektronix 410x and 420x series terminals
  25.  *
  26.  * AUTHORS
  27.  *   Colin Kelley, Thomas Williams
  28.  * 
  29.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  30.  * 
  31.  */
  32.  
  33. /* Tektronix 410X and 420X driver written by Cary D. Renzema.
  34.  * email address: caryr@vice.ico.tek.com
  35.  *
  36.  * I've tested this driver on the following terminals: 4106, 4107A, 4109
  37.  * and 4207.  It should work, without editing, on other terminals in the
  38.  * 410x and 420x families.  It will probably need to be changed to work
  39.  * on a 4105 (screen size and character rotation are two guesses).  This
  40.  * file can also be used as a start for a 411x driver.
  41.  *
  42.  * Cary R.
  43.  * April 5, 1990
  44.  */
  45.  
  46. #ifdef T410X
  47.  
  48. #define T410XXMAX 4095
  49. #define T410XYMAX 3131
  50.  
  51. #define T410XVCHAR    71
  52. #define T410XHCHAR    51
  53. #define T410XVTIC    36
  54. #define T410XHTIC    36    
  55.  
  56. static int T410X_angle=0;
  57.  
  58. T410X_init()
  59. {
  60.     (void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
  61.     (void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
  62. /*
  63.      1. set tek mode
  64.      2. set character path to 0 (characters placed equal to rotation)
  65.      3. set character size to 59 height
  66.      4. set character precision to string
  67.      5. set character text index to 1
  68.      6. set character write mode to overstrike
  69.      7. clear the view
  70.      8. clear the segments
  71.      9. clear the dialog buffer
  72.     10. set ansi mode
  73. */
  74.     (void) fflush(outfile);
  75. }
  76.  
  77.  
  78. T410X_reset()
  79. {
  80.     (void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
  81. /*
  82.     1. set tek mode
  83.     2. clear the dialog buffer
  84.     3. set ansi mode
  85. */
  86.     (void) fflush(outfile);
  87. }
  88.  
  89.  
  90. T410X_graphics()
  91. {
  92.     (void) fprintf(outfile, "\033%%!0\033\014\033LV0");
  93. /*
  94.     1. set tek mode
  95.     2. clear the screen
  96.     3. set dialog area invisible
  97. */
  98.     (void) fflush(outfile);
  99. }
  100.  
  101. T410X_text()
  102. {
  103.     (void) fprintf(outfile, "\033LV1\033%%!1");
  104. /*
  105.     1. set dialog area visible
  106.     2. set ansi mode
  107. */
  108.     (void) fflush(outfile);
  109. }
  110.  
  111.  
  112. T410X_move(x, y)
  113. unsigned int x, y;
  114. {
  115.     (void) fprintf(outfile, "\033LF");
  116.     (void) T410X_encode_x_y(x, y);
  117.     (void) fflush(outfile);
  118. }
  119.  
  120.  
  121. T410X_vector(x, y)
  122. unsigned int x, y;
  123. {
  124.     (void) fprintf(outfile, "\033LG");
  125.     (void) T410X_encode_x_y(x, y);
  126.     (void) fflush(outfile);
  127. }
  128.  
  129.  
  130. T410X_point(x, y, number)
  131. unsigned int x, y;
  132. int number;
  133. {
  134.     (void) fprintf(outfile, "\033MM");
  135.     (void) T410X_encode_int(max(number, 0)%11);
  136.     (void) fprintf(outfile, "\033LH");
  137.     (void) T410X_encode_x_y(x, y);
  138.     (void) fflush(outfile);
  139. }
  140.  
  141.  
  142. T410X_linetype(linetype)
  143. int linetype;
  144. {
  145.     switch (linetype) {
  146.         case -1:
  147.             (void) fprintf(outfile, "\033ML5");
  148.             break;
  149.         case -2:
  150.             (void) fprintf(outfile, "\033ML?");
  151.             break;
  152.         default:
  153.             (void) fprintf(outfile, "\033ML");
  154.             (void) T410X_encode_int(linetype%14+2);
  155.             break;
  156.     }
  157.     (void) fprintf(outfile, "\033MV");
  158.     (void) T410X_encode_int(max(linetype, 0)%8);
  159.     (void) fflush(outfile);
  160. }
  161.  
  162.  
  163. T410X_put_text(x, y, str)
  164. unsigned int x, y;
  165. char str[];
  166. {
  167.  
  168.     if (T410X_angle == 0) {
  169.         (void) T410X_move(x, y-T410XVCHAR/2+6);
  170.         (void) fprintf(outfile, "\033MR00");
  171.     } else {
  172.         (void) T410X_move(x+T410XHCHAR/2-6, y);
  173.         (void) fprintf(outfile, "\033MRE:0");
  174.     }
  175.     (void) fprintf(outfile, "\033LT");
  176.     (void) T410X_encode_int(strlen(str));
  177.     (void) fputs(str, outfile);
  178.     (void) fflush(outfile);
  179. }
  180.  
  181. T410X_text_angle(ang)
  182. int ang;
  183. {
  184.  
  185.     T410X_angle = ang;
  186.     return(TRUE);
  187. }
  188.  
  189. /* These last two routines are based on fortran code found in the
  190.  * 4106/4107/4109/CX PROGRAMMERS manual.
  191.  */
  192.  
  193. T410X_encode_x_y(x, y)
  194. unsigned int x, y;
  195. {
  196.     static char chix=0, chiy=0, cloy=0, ceb=0;
  197.  
  198.     register unsigned int hix, lox, hiy, loy, eb, lx, ly;
  199.  
  200.     lx = (x <= T410XXMAX) ? x : T410XXMAX;
  201.     ly = (y <= T410XYMAX) ? y : T410XYMAX;
  202.  
  203.     hix = lx/128 + 32;
  204.     lox = (lx/4)%32 + 64;
  205.     hiy = ly/128 + 32;
  206.     loy = (ly/4)%32 + 96;
  207.     eb = (ly%4)*4 + lx%4 + 96;
  208.  
  209.     if (chiy != hiy) (void) putc(hiy, outfile);
  210.     if (ceb != eb) (void) putc(eb, outfile);
  211.     if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
  212.     if (chix != hix) (void) putc(hix, outfile);
  213.     (void) putc(lox, outfile);
  214.  
  215.     chix = hix;
  216.     chiy = hiy;
  217.     cloy = loy;
  218.     ceb = eb;
  219. }
  220.  
  221.  
  222. T410X_encode_int(number)
  223. int number;
  224. {
  225.     register unsigned int mag, hi1, hi2, lo;
  226.  
  227.     mag = abs(number);
  228.  
  229.     hi1 = mag/1024 + 64;
  230.     hi2 = (mag/16)%64 + 64;
  231.     lo = mag%16 + 32;
  232.  
  233.     if (number >= 0) lo += 16;
  234.  
  235.     if (hi1 != 64) (void) putc(hi1, outfile);
  236.     if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
  237.     (void) putc(lo, outfile);
  238.  
  239. }
  240.  
  241.  
  242. #endif /* T410X */
  243.